package com.car.shopping.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.car.commons.core.model.Result;
import com.car.shopping.client.model.user.SelectById;
import com.car.shopping.controller.form.FindGoodsForPageForm;
import com.car.shopping.controller.form.PageForm;
import com.car.shopping.entity.GoodsInfo;
import com.car.shopping.entity.GoodsModifyLog;
import com.car.shopping.service.GoodsModifyLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 董旭
 * @since 2024-08-28
 */
@RestController
@RequestMapping("/goodsModifyLog")
@Api(tags = "商品日志相关接口")
public class GoodsModifyLogController {
    @Autowired
    private GoodsModifyLogService goodsModifyLogService;
    @ApiOperation("条件分页查询")
    @PostMapping("/findLogForPage.pt")
    public Result findLogForPage(@RequestBody PageForm form)throws Exception{
        Page<GoodsModifyLog> result = goodsModifyLogService.findLogForPage(form);
        return Result.getResult().setMsg("查询成功").setData(result);
    }
    @ApiOperation("根据id查管理员名字")
    @PostMapping("/selectById.pt")
    public Result<SelectById> selectById(@RequestParam("adminId") Integer adminId) throws Exception {
        // 调用服务层方法获取数据
        SelectById selectById = goodsModifyLogService.selectById(adminId);

        // 检查数据是否为空，并返回适当的结果
        if (selectById != null) {
            return Result.getResult(SelectById.class).setMsg("查询成功").setData(selectById);
        } else {
            return Result.<SelectById>getResult().setMsg("管理员不存在").setCode(404);
        }
    }







}

